﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Moq;

namespace MoqContrib.AutoMock.All.Tests.TheContainer
{
    [TestFixture]
    public abstract class WhenResolvingServices<T>
        where T : IDoContainerStuff, IAutoMockContainer, new()
    {
		private T container;

        [System.ComponentModel.DefaultValue(false)]
        protected bool IsCsl { get; set; }

        #region Types used for testing
        public interface IService { }
        #endregion

        [SetUp]
        public void Given()
        {
			container = new T();
        }

        [Test]
        public virtual void I_still_return_objects_registered_normally()
        {
			var mock = new Mock<IService>();
            container.RegisterServiceAs<IService>(mock.Object);
            var result = container.ResolveService<IService>();
            Assert.That(result, Is.SameAs(mock.Object));
        }

        [Test]
        public void I_will_give_a_mock_if_I_dont_have_a_service()
		{
			var result = container.ResolveService<IService>();
            Assert.That(result, Is.Not.Null);
			Assert.That(result, Is.InstanceOf<IService>());
        }
    }
}
